package com.yunkeji.admin.controller.sys;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.yunkeji.common.annotation.Log;
import com.yunkeji.common.core.controller.BaseController;
import com.yunkeji.common.core.domain.PageQuery;
import com.yunkeji.common.core.domain.R;
import com.yunkeji.common.core.page.TableDataInfo;
import com.yunkeji.common.enums.BusinessType;
import com.yunkeji.dao.domain.InviteReward;
import com.yunkeji.dao.vo.InviteRewardVo;
import com.yunkeji.system.service.IInviteRewardService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 邀请奖励
 *
 * @author 雷擎宇
 * @date 2024-12-30
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/inviteReward")
public class InviteRewardController extends BaseController {

    private final IInviteRewardService inviteRewardService;

    /** 查询列表 */
    @SaCheckPermission("system:inviteReward:list")
    @GetMapping("/list")
    public TableDataInfo<InviteRewardVo> list(InviteReward bo, PageQuery pageQuery) {
        return inviteRewardService.queryPageList(bo, pageQuery);
    }

    /** 新增 */
    @SaCheckPermission("system:inviteReward:add")
    @Log(title = "新增邀请奖励配置", businessType = BusinessType.INSERT)
    @PostMapping()
    public R<Void> add(@RequestBody InviteReward bo) {
        inviteRewardService.insert(bo);
        return R.ok();
    }

    /** 修改 */
    @SaCheckPermission("system:inviteReward:edit")
    @Log(title = "邀请奖励配置", businessType = BusinessType.UPDATE)
    @PutMapping()
    public R<Void> edit(@RequestBody InviteReward bo) {
        inviteRewardService.edit(bo);
        return R.ok();
    }

}
